<template>
  <!--header start 个人信息-->
  <div class="newhome_my_box">
    <div class="my_header">
     
          <div class="my_msg">
            <div class="user_pic" @click="pushPath('/changeAvatar')">
              <img :src="userInfo.customerHead" class="not_save_img">
            </div>
             <div class="newhome_my_nickname">
              <label>
                <p>账号: {{userInfo.customerNumber}} </p>
              </label>
            </div>
          </div>
    </div>
    <div class="newhome_asflex">
			<div class="item">
        <p>分红点</p>
				<p class="red">{{DQNum||"0.00"}}</p>
		
			</div>
      <div class="sidebar"></div>
			<div  class="item"> 
        <p>股权</p>
				<p class="red">{{PSNum||"0.00"}}</p>
			</div>
		</div>
    <!--header end-->
      <div class="footer_new">
        <van-button type="primary" size="large" @click="exit">{{$t('lang.Logout')}}</van-button>
      </div>

  </div>
</template>
<script>
import { MessageBox } from "mint-ui";
import { Toast,Dialog  } from "vant";

export default {
  name: "my",
  data() {
    return {
      userInfo: {},
      isAuth: false,
      exitPopup:false,
      DQNum:0,
      PSNum:0,
      usePoint:0

    };
  },
 
  computed: {
    msgNum() {
      return this.$store.state.msgNum;
    }
  },
  created() {},
  watch: {
    $route(val, oldval) {
      if (oldval.fullPath.indexOf("?") != -1) {
        if (this.exitPopup) {
          this.exitPopup = false;
        }
      }
    }
  },
  mounted() {
    this.$store.commit("updateSelected", 3);
    this.$store.commit("updateNeedShowFooter", true);
    this.getUserInfo();
    this.selectAccount();
    this.selectChildAccount();
  },
  methods: {
    getUserInfo() {
      this.$ajax(this.$api.getMyInfo).then(res => {
        if (res.code === 0 && res.msg) {
          this.userInfo = res.msg;
          this.customerType=res.msg.customerType;
          this.isAuth = res.msg.flagAuth == 0 ? false : true;
          localStorage.setItem("userInfo", JSON.stringify(res.msg));
          
        }
      });
    },

    // POST /api/customer/selectAccount


    //child/childList
    selectAccount(){
      this.$ajax(this.$api.selectAccount,).then(res => {
            if (res.code === 0) {
              if (res.msg) {
                this.PSNum=res.msg.staticMoney.toFixed(4);
                this.usePoint=res.msg.usePoint.toFixed(4);
              }
            }
      });
    },

    selectChildAccount(){
			// 个人钱包信息
      this.$ajax(this.$api.childList).then(
        res=>{
          if(res.code==0){
            let fixedStockSum=0;
            let useStockSum=0;

            let arr = res.msg.list;
            arr.forEach(function (item, index) {
                console.log(item);
                fixedStockSum+=item['fixedStock'];
                useStockSum+=item['useStock'];
            });
            this.DQNum=this.usePoint/1.609+fixedStockSum+useStockSum;
            this.DQNum=this.DQNum.toFixed(4);
          }
        }
      )
    },
    exit() {
      localStorage.setItem("token", "");
      this.$router.replace("/login");
    },
    
  }
};
</script>
<style>

.newhome_my_box {
  background: #fff;
}
/*header start*/
.newhome_my_box .my_header {
  background: url(../../assets/img/my/newinit_bg.png);
  background-attachment: fixed;
  background-repeat:no-repeat; 
  background-size: 100%;
  height: 50%;
}

.newhome_my_box .my_header .my_msg {
  
    
    padding-top: 17%;
}
.user_pic{
  width: 100px;
  height: 100px;
  margin: 0 auto;
  
}
.newhome_my_nickname {
    width: 139px;
    margin: 0 auto;
}


.newhome_my_nickname p {
  color: #fff;
  font-size: 18px;
  padding-top: 25px;
}
/*header end*/
.newhome_asflex {
  display: flex;
  width: 93%;
  height: 90px;
  margin: 0 3.5%;
  border-radius: 0.3rem;
  justify-content: space-between;
  background: #fff;
  padding: 10px 0;
  filter:progid:DXImageTransform.Microsoft.Shadow(color=#909090,direction=120,strength=4);/*ie*/
  -moz-box-shadow: 2px 2px 10px #909090;/*firefox*/
  -webkit-box-shadow: 2px 2px 10px #909090;/*safari或chrome*/
  box-shadow:2px 2px 10px #909090;/*opera或ie9*/
  position:absolute;
  top:270px;
}
.newhome_asflex .sidebar {
   float:left;width: 1px;height: 80%; background: #F2F2F2;
   margin-left: 1px;
  }

.newhome_asflex .item {
    padding: 20px 25px;
    font-size: 16px;
  }

  .newhome_asflex .item  p{
    padding-bottom: 5px;
  }

  .newhome_asflex .item .red{
    color: red;
    font-size: 18px;
  }
  .footer_new {
    bottom: 20%;
    position: fixed !important;
    width: 90%;
    padding: 10px 5%;
    border-top: 1px #eee solid;
    background-color: #fff;
    z-index: 10;
}



</style>
